<?php
/**
 * Created by mq.
 * User: mq
 * Date: 18-8-11
 * Time: 下午5:14
 */

namespace app\admin\controller;

use common\controller\AdminBase;
use http\Env\Request;
use think\Cache;
use think\Db;
use think\File;
use think\Loader;
use think\Session;
use tool\auth;

class Authpage extends AdminBase{

    public function index($uid){

        if($this->request->isPost()){
            $data = $this->request->request();
            if(isset($data['auth'])){
                $postAuth = implode(',',$data['auth']);
                $res = Db::table('admin')->where('id', $uid)->update(['auth' => $postAuth, 'super' => $data['super']]);
                $res ? $this->success('修改成功！'):$this->error('修改失败！');
            }
        }

        $user = Db::table('admin')->where('id', $uid)->find();
        $haveAuth = $user['auth'] ? explode(',',$user['auth']):[];

        $this->assign('auth', auth::conf());
        $this->assign('haveAuth',$haveAuth);
        $this->assign('user', $user);
        return $this->fetch();
    }


}